<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>解析 CSV 字符串为一个数组</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.sscanf.html">sscanf</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.str-ireplace.html">str_ireplace</a></div>
 <div class="up"><a href="ref.strings.html">字符串函数</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="function.str-getcsv" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">str_getcsv</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.3.0)</p><p class="refpurpose"><span class="refname">str_getcsv</span> &mdash; <span class="dc-title">
   解析 CSV 字符串为一个数组
  </span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.str-getcsv-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="type">array</span> <span class="methodname"><strong>str_getcsv</strong></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$input</code></span>
   [, <span class="methodparam"><span class="type">string</span> <code class="parameter">$delimiter</code><span class="initializer"> = &#039;,&#039;</span></span>
   [, <span class="methodparam"><span class="type">string</span> <code class="parameter">$enclosure</code><span class="initializer"> = &#039;&quot;&#039;</span></span>
   [, <span class="methodparam"><span class="type">string</span> <code class="parameter">$escape</code><span class="initializer"> = &#039;\\&#039;</span></span>
  ]]] )</div>

  <p class="para rdfs-comment">
   与 <span class="function"><a href="function.fgetcsv.html" class="function">fgetcsv()</a></span> 类似，该函数解析一个输入字符串，而非像 <span class="function"><a href="function.fgetcsv.html" class="function">fgetcsv()</a></span> 那样以文件作为它的输入。
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.str-getcsv-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
<em><code class="parameter">input</code></em></dt>

     <dd>

      <p class="para">
       待解析的字符串。
      </p>
     </dd>

    
    
     <dt>
<em><code class="parameter">delimiter</code></em></dt>

     <dd>

      <p class="para">
       设定字段界定符（仅单个字符）。
      </p>
     </dd>

    
    
     <dt>
<em><code class="parameter">enclosure</code></em></dt>

     <dd>

      <p class="para">
       设定字段包裹字符（仅单个字符）。
      </p>
     </dd>

    
    
     <dt>
<em><code class="parameter">escape</code></em></dt>

     <dd>

      <p class="para">
       设置转义字符（仅单个字符）。默认为反斜线（<em>\</em>）。
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.str-getcsv-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   返回一个包含读取到的字段的索引数组。
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.str-getcsv-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="function.fgetcsv.html" class="function" rel="rdfs-seeAlso">fgetcsv()</a> - 从文件指针中读入一行并解析 CSV 字段</span></li>
   </ul>
  </p>
 </div>

</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.sscanf.html">sscanf</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.str-ireplace.html">str_ireplace</a></div>
 <div class="up"><a href="ref.strings.html">字符串函数</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
